<?php

namespace App\Http\Controllers\Vip;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Models\Divide\PdLevel;
use Illuminate\Http\Request;

class VipController extends Controller
{
    //
    use ResponseData;
    public function getVipList(PdLevel $model, Request $request){
        $data = $model->query()->where('mode',$request->mode)->get();
        return $this->success($data);
    }
    // 获取vipList
    public function bigVipList(PdLevel $model, Request $request){
        if(!$request->filled('mode')){
            return $this->failed('请传递mode');
        }
        $big = $model->query()
            ->where('mode',$request->mode)
            ->where('level','>',2)
            ->where('level','<',7)
            ->orderByDesc('level')
            ->get();
        $little = $model->query()
            ->where('mode',$request->mode)
            ->where('level','>',-1)
            ->where('level','<',3)
            ->orderByDesc('level')
            ->get();
        $status = 2;
        $vip  = true;
        return $this->success(compact('big','little','status','vip'));
    }
    public function VipSwitch(PdLevel $model, Request $request){
        $model = $model->query()
            ->where('level',$request->level)
            ->where('mode',$request->mode);
        switch ($request->type){
            case 1:
                $model->update(['is_borker'=>$request->status]);
                break;
            case 2:
                $model->update(['is_sale'=>$request->status]);
                break;
            case 3:
                $model->update(['is_inte'=>$request->status]);
                break;
            case 5:
                $model->update(['is_inte_buy'=>$request->status]);
                break;

        }
//            ->update(['is_borker'=>$request->type]);
        return $this->success($model);
    }
}
